//-
//- Copyright (c) Microsoft. All rights reserved.
//- Licensed under the MIT license. See LICENSE file in the project root for full license information.
//-

extends ../layout

block content
  - var repo = repository
  .container
    .row: .col-sm-12
      .nav
        ul.pager.zero-pad-bottom
          li.previous
            a(href='/' + organization.name + '/repos/' + repository.name)
              span(aria-hidden=true) &larr;
              = ' Back to the ' + repository.name + ' repository'
      - var hugeHeading = false
      h1(class={huge: hugeHeading})
        a(href='https://github.com/' + repo.full_name, target="_blank")= repo.name
        if repo.private === true
          | &nbsp;
          .label.label-warning(class={shrink66: !hugeHeading, shrink50: hugeHeading}) Private
      h6= repo.full_name.replace('/' + repo.name, '') + ' organization'
      //-if repo.description
        p.lead=repo.description

      hr
      h1 Contribution license agreement settings

    .row
      .col-md-10

        if claSettings && claSettings.enabled
          - var cla = claSettings
          ul.list-inline.list-horizontal-space
            li
              | Status
              br
              strong Active
            if cla.mails
              li
                | Notifying
                br
                strong= cla.mails
            if cla.legalEntity
              li
                | Legal entity
                br
                strong= cla.legalEntity
            if cla.updatedOn && cla.updatedOn.fromNow
              li
                | Configuration updated
                br
                strong= cla.updatedOn.fromNow()
            //-if cla.webhookUrl
              li
                | Webhook
                br
                strong= cla.webhookUrl
        else
          p This repository does not currently have the CLA enabled.

        h3 #{claSettings && claSettings.enabled ? 'Update' : 'Enable'} settings
        form.form-horizontal(method='post')
          h4 Legal entity
          if claSettings && claSettings.enabled
            if claSettings.legalEntity
              p: strong= claSettings.legalEntity
            p The legal entity cannot be changed after the fact. Please contact operations if this should change.
          else
            if claSettings && claSettings.teams
              select.form-control(name='legalEntity')
                each team, key in claSettings.teams
                  option(value=key)= key
          h4 Pull request notifications
          p To receive notification whenever a pull request is created, provide the e-mail addresses to notify. This address needs to be able to accept e-mail from outside the organization.
          p: input.form-control(type='text', name='emails', placeholder='Optional comma-separated list of e-mail addresses to set', value= claSettings ? claSettings.mails : null)
          p: input.btn.btn-primary(type='submit', value='Set')

        hr

        p.
          Contribution License Agreements (CLAs) make accepting contributions and working with
          the open source community much easier while protecting contributors and copyright holders
          including the legal entity.
        p.
          The CLA bots detect whether someone is contributing a large enough change to require a CLA
          to be signed, and in the case that it is an employee (or contractor making a contribution
          within the scope of their statement of work), no CLA may be required, allowing the team to
          integrate the change even sooner.
